package com.ifcar.app.fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.ifcar.app.util.ThemeSettingsHelper;
import com.ifcar.app.view.LoadingListView;
import com.ifcar.app.activity.R;

public abstract class NRPullLoadingListFrament extends
		NRAbsPullLoadingListFrament {

	@Override
	public void onViewCreatedNR(View view, Bundle savedInstanceState) {
		super.onViewCreatedNR(view, savedInstanceState);

		LoadingListView loadingListView = (LoadingListView) view
				.findViewById(R.id.loading_list);
		
		if (hasMoreView()) {
			LayoutInflater inflate = LayoutInflater.from(getActivity());
			View moreView = inflate.inflate(R.layout.more_layout, null);
			loadingListView.setLoadingMoreView(moreView, R.id.show_more_button);
		}
		
		attachLoadingListView(loadingListView);
	}

	@Override
	public void onApplyTheme() {
		super.onApplyTheme();
		LoadingListView loadingListView = getLoadingListView();
		if (loadingListView != null) {
			ThemeSettingsHelper themeSettingsHelper = getThemeSettingsHelper();
			Context context = getActivity();
			themeSettingsHelper
					.setListViewDivider(context, loadingListView.getListView(),
							R.drawable.list_divider_line);
			
			Button moreButton = getMoreButton();
			if (moreButton != null) {
				themeSettingsHelper.setViewBackgroud(context, moreButton,
						R.drawable.netease_big_button);
				themeSettingsHelper.setTextViewColor(context, moreButton,
						R.color.list_title_color);
			}
		}
	}
}
